<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.geping.etl.common.util.VariableUtils" %>
<%@ page import="com.geping.etl.common.entity.Sys_Auth_Role_Resource" %>
<%@ page import="com.geping.etl.utils.EnvUitl" %>
<%@ page import="com.geping.etl.common.util.Constants" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    VariableUtils vu = (VariableUtils) request.getSession().getAttribute("vu");
    Set<Sys_Auth_Role_Resource> operateSet = vu.getOperateReportSet();
    String bxSyn = (String) request.getSession().getAttribute("bxSyn");
    String taiwanUser = (String) request.getSession().getAttribute("taiwanUser");
    String waihuiUser = (String) request.getSession().getAttribute("waihuiUser");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>人员信息</title>
    <%@include file="head.jsp" %>
</head>
<body>
<table class="easyui-datagrid" title="人员信息" id="dg1"
       data-options="singleSelect:true,rownumbers:true,toolbar:'#tb',autoRowHeight:false,pagination:true,pageSize:25,pageList:[15,25,35]"
       style="height: 460px">
    <thead>
    <tr>
        <th data-options="field:'id',width:80,align:'center',hidden:true">ID</th>
        <th data-options="field:'loginId',width:80,align:'center'">登录账号</th>
        <th data-options="field:'userEname',width:80,align:'center'">用户英文名</th>
        <th data-options="field:'userCname',width:80,align:'center'">用户中文名</th>
        <th data-options="field:'password',width:100,align:'center',hidden:true">密码</th>
        <th data-options="field:'departId',width:80,align:'center',hidden:true">部门ID</th>
        <%
            if (taiwanUser == null || !taiwanUser.equals("on")) {
        %>
        <th data-options="field:'departmentName',width:80,align:'center'">部门名称</th>
        <%
        } else {
        %>
        <th data-options="field:'departmentName',width:80,align:'center'">分行部门名称</th>
        <%
            }
        %>
        <th data-options="field:'tel',width:80,align:'center',hidden:true">联系电话</th>
        <th data-options="field:'startDate',width:80,align:'center',hidden:true">开始时间</th>
        <c:if test="${sessionScope.user_more_org == 'on'}">
            <th data-options="field:'endDate',width:300,align:'center',hidden:true">所属机构id</th>
        </c:if>
        <th data-options="field:'createTime',width:140,align:'center'">创建时间</th>
        <th data-options="field:'enabled',width:100,align:'center',hidden:true">启用标识</th>
        <th data-options="field:'isDelete',width:80,align:'center',hidden:true">是否删除</th>
        <th data-options="field:'lastLoginDate',width:140,align:'center'">最后登录时间</th>
        <th data-options="field:'isDeptValue',width:80,align:'center',hidden:true">分部门标识</th>
        <th data-options="field:'systemDept',width:100,align:'center',hidden:true">分部门</th>
        <th data-options="field:'handleperson',width:100,align:'center'">操作人</th>
        <th data-options="field:'handledate',width:140,align:'center'">操作时间</th>
    </tr>
    </thead>

    <tbody>
    <c:forEach items="${list}" var="li">
        <tr>
            <td>${li.id}</td>
            <td>${li.loginid}</td>
            <td>${li.userename}</td>
            <td>${li.usercname}</td>
            <td>${li.password}</td>
            <td>${li.departid}</td>
            <td>${li.departmentname}</td>
            <td>${li.tel}</td>
            <td>${li.startdate}</td>
            <c:if test="${sessionScope.user_more_org == 'on'}">
                <td>${li.enddate}</td>
            </c:if>
            <td>${li.createtime}</td>
            <td>${li.enabled}</td>
            <td>
                <c:if test="${li.isdelete == 'N'}">
                    未删除
                </c:if>
                <c:if test="${li.isdelete == 'Y'}">
                    已删除
                </c:if>
            </td>
            <td>${li.lastlogindate}</td>
            <td>${li.isdept}</td>
            <td>${li.systemdept}</td>
            <td>${li.handleperson}</td>
            <td>${li.handledate}</td>
        </tr>
    </c:forEach>
    </tbody>
</table>

<div id="tb" style="padding: 5px; height: auto;">
    用户中文名: <input type="text" style="width:173px; height: 21px" id="userCname" name="userCname"
                       value="${userCname}">&nbsp;&nbsp;
    <a class="easyui-linkbutton" iconCls="icon-search" onclick="selectRecordByName()">查询</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <%
        System.out.println("Constants.BX_SYN_USER_ON:" + Constants.BX_SYN_USER_ON);
        System.out.println("bxSyn:" + bxSyn);
        for (Sys_Auth_Role_Resource sarr : operateSet) {
            System.out.println("sarr.getResValue():" + sarr.getResValue());
            System.out.println("sarr.getResValue().equals(\"ADD\"):" + sarr.getResValue().equals("ADD"));
            if (sarr.getResValue().equals("ADD")) {
                if (!Constants.BX_SYN_USER_ON.equals(bxSyn)) {
                    if (taiwanUser != null && "on".equals(taiwanUser)) {
    %>
    <a class="easyui-linkbutton" iconCls="icon-add" onclick="addUser(2)">新增</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <%
    } else if (waihuiUser != null && "on".equals(waihuiUser)) {
    %>
    <a class="easyui-linkbutton" iconCls="icon-add" onclick="addUser(3)">新增</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%
    } else {
    %>
    <a class="easyui-linkbutton" iconCls="icon-add" onclick="addUser(1)">新增</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    <%
        }
    %>
    <%
        }
    } else if (sarr.getResValue().equals("EDIT")) {
        if (taiwanUser != null && "on".equals(taiwanUser)) {
    %>
    <a class="easyui-linkbutton" iconCls="icon-edit" onclick="editUser(2)">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%--//北现同步开关是否开启--%>
    <%
    } else if (waihuiUser != null && "on".equals(waihuiUser)) {
    %>
    <a class="easyui-linkbutton" iconCls="icon-edit" onclick="editUser(3)">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%
    } else {
    %>
    <a class="easyui-linkbutton" iconCls="icon-edit" onclick="editUser(1)">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <%
        }
        if (!Constants.BX_SYN_USER_ON.equals(bxSyn)) {
    %>
    <a class="easyui-linkbutton" iconCls="icon-edit" onclick="editPasswordUser()">重置用户密码</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <% }
    } else if (sarr.getResValue().equals("CHECK")) {

    %>
    <%--  <a class="easyui-linkbutton" iconCls="icon-ok" onclick="agreenApply()">同意申请</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <a class="easyui-linkbutton" iconCls="icon-cross" onclick="refuseApply()">拒绝申请</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
    <%
            }
        }
        if (!Constants.BX_SYN_USER_ON.equals(bxSyn)) {
    %>


    <%--//北现同步开关是否开启--%>
    <a class="easyui-linkbutton" iconCls="icon-remove" onclick="remove()">删除用户</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <% } %>
    <!-- <a class="easyui-linkbutton" iconCls="icon-page-excel" onclick="exportExcel()">导出</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <a class="easyui-linkbutton" iconCls="icon-page-excel" onclick="importExcel()">导入</a> -->
    <a class="easyui-linkbutton" iconCls="icon-edit" onclick="userResource()">查看手工报表</a>
</div>


<!-- 新增用户dialog -->
<div style="visibility: hidden;">
    <div id="addDialog" class="easyui-dialog" title="新增用户"
         data-options="iconCls:'icon-save',toolbar:'#tbForAddDialog'"
         style="width: 900px; height: 460px; align-items: center;">
        <!--   新增对话框的工具栏  -->
        <div id="tbForAddDialog" style="padding-left: 30px; padding-top: 10px">

            <%
                if (taiwanUser != null && "on".equals(taiwanUser)) {
            %>
            <a id="saveButtonId" class="easyui-linkbutton" data-options="iconCls:'icon-save'"
               onclick="saveForAddDialog(2)">保存</a>&nbsp;&nbsp;
            <a class="easyui-linkbutton" data-options="iconCls:'icon-undo'" onclick="resetForAdd(2)">重置</a>
            <%
            } else if (waihuiUser != null && "on".equals(waihuiUser)) {
            %>
            <a id="saveButtonId" class="easyui-linkbutton" data-options="iconCls:'icon-save'"
               onclick="saveForAddDialog(2)">保存</a>&nbsp;&nbsp;
            <a class="easyui-linkbutton" data-options="iconCls:'icon-undo'" onclick="resetForAdd(2)">重置</a>
            <%
            } else {
            %>
            <a id="saveButtonId" class="easyui-linkbutton" data-options="iconCls:'icon-save'"
               onclick="saveForAddDialog(1)">保存</a>&nbsp;&nbsp;
            <a class="easyui-linkbutton" data-options="iconCls:'icon-undo'" onclick="resetForAdd(1)">重置</a>
            <%
                }
            %>
        </div>

        <!-- 信息录入 -->
        <form id="formForAddUser" method="post">
            <div style="padding-top: 20px">
                <table style="padding-left: 30px">
                    <input type="hidden" name="randSession" value="<%=request.getSession().getAttribute("authId")%>"/>
                    <tr>
                        <td align="right">登录账号:</td>
                        <td><input type="text" name="loginId_add" id="loginId_add"
                                   onblur="loginIdValidate('loginId_add');ipValidate('ip_add');"
                                   style="height: 21px; width: 173px"/></td>
                        <td style="text-align: left; font-size: small;" id="loginId_add_Html"><span style="color: red">*数字、字母、下划线或中文组合,长度不超过20</span>
                        </td>
                    </tr>

                    <tr>
                        <td align="right">用户英文名:</td>
                        <td><input type="text" name="userEname_add" id="userEname_add"
                                   onblur="userEnameValidate('userEname_add')" style="height: 21px; width: 173px"/></td>
                        <td style="text-align: left; font-size: small;" id="userEname_add_Html"><span
                                style="color: red">*字母,长度不超过20</span></td>
                    </tr>

                    <tr>
                        <td align="right">用户中文名:</td>
                        <td><input type="text" name="userCname_add" id="userCname_add"
                                   onblur="userCnameValidate('userCname_add')" style="height: 21px; width: 173px"/></td>
                        <td style="text-align: left; font-size: small;" id="userCname_add_Html"><span
                                style="color: red">*中文,长度不超过20</span></td>
                    </tr>


                    <%--	<c:if test="${sessionScope.user_more_org == 'on'}">
                            <c:forEach items="${subjectList}" var="subject">
                                <tr>
                                    <td align="right">${subject.subjectName}机构代码:</td>
                                    <td>
                                        <select class="easyui-combobox" name="orgId_add${subject.id}" id="add_orgId${subject.id}" editable=false style="height: 21px; width: 173px">
                                            <option value="" selected="selected">---请选择机构代码---</option>
                                            <c:forEach items="${orgList}" var="ol">
                                                <option value="${ol.orgId}">${ol.orgId}-${ol.orgName}</option>
                                            </c:forEach>
                                        </select>
                                    </td>
                                </tr>
                            </c:forEach>
                        </c:if>
                        <c:if test="${sessionScope.user_more_org != 'on'}">
                            <tr>
                                <td align="right">机构代码</td>
                                <td>
                                    <select class="easyui-combobox" name="orgId_add" id="orgId_add" editable=false style="height: 21px; width: 173px">
                                        <!-- <option value="" selected="selected">---请选择机构代码---</option> -->
                                        <c:forEach items="${orgList}" var="ol">
                                            <option value="${ol.orgId}">${ol.orgId}-${ol.orgName}</option>
                                        </c:forEach>
                                    </select>
                                </td>
                            </tr>
                        </c:if>--%>
                    <tr>
                        <%
                            if (taiwanUser == null || !taiwanUser.equals("on")) {
                        %>
                        <td align="right">部门名称:</td>
                        <td>
                            <select class="easyui-combobox" name="departId_add"
                                    id="departId_add1" editable=false
                                    style="height: 21px; width: 173px"
                                    data-options="onSelect:function(record){departmentValidate('departId_add1');}">
                                <option value="" selected="selected">---请选择部门---</option>
                                <c:forEach items="${departmentList}" var="dl">
                                    <option value="${dl.departmentId}">${dl.departmentName}</option>
                                </c:forEach>
                            </select></td>
                        <td style="text-align: left; font-size: small;" id="departId_add1_Html"><span
                                style="color: red">*请选择部门</span></td>
                        <%
                        } else {
                        %>
                        <td align="right">分行部门名称:</td>
                        <td>
                            <select class="easyui-combobox" name="departId_add"
                                    id="departId_add2" editable=false
                                    style="height: 21px; width: 173px"
                                    data-options="onSelect:function(record){departmentValidate('departId_add2');}">
                                <option value="" selected="selected">---请选择分行部门---</option>
                                <c:forEach items="${departmentList}" var="dl">
                                    <option value="${dl.departmentId}">${dl.departmentName}</option>
                                </c:forEach>
                            </select></td>
                        <td style="text-align: left; font-size: small;" id="departId_add2_Html"><span
                                style="color: red">*请选择分行部门</span></td>
                        <%
                            }
                        %>
                    </tr>

                    <%--<tr>
                        <td align="right">联系电话:</td>
                        <td><input type="text" name="tel_add" id="tel_add" style="height: 21px; width: 173px" /></td>
                    </tr>

                    <tr>
                        <td align="right">移动电话:</td>
                        <td><input type="text" name="mobile_add" id="mobile_add" style="height: 21px; width: 173px" /></td>
                    </tr>

                    <tr>
                        <td align="right">地址:</td>
                        <td><input type="text" name="address_add" id="address_add" style="height: 21px; width: 173px" /></td>
                    </tr>--%>
                    <%--	<%
                            if (taiwanUser != null && "on".equals(taiwanUser)) {
                        %>
                        <tr>
                            <td align="right">邮箱:</td>
                            <td><input type="text" name="email_add" id="email_add2" onblur="emailValidate('email_add2')" style="height: 21px; width: 173px" /></td>
                            <td style="text-align: left; font-size: small;" id="email_add2_Html"><span style="color: red">*请输入邮箱</span></td>
                        </tr>
                        <%
                            }else if(waihuiUser != null && "on".equals(waihuiUser)){
                        %>
                        <tr>
                            <td align="right">邮箱:</td>
                            <td><input type="text" name="email_add" id="email_add3" onblur="emailValidate('email_add3')" style="height: 21px; width: 173px" /></td>
                            <td style="text-align: left; font-size: small;" id="email_add3_Html"><span style="color: red">*请输入邮箱</span></td>
                        </tr>
                        <%
                            }else {
                        %>
                        <tr>
                            <td align="right">邮箱:</td>
                            <td><input type="text" name="email_add" id="email_add1" style="height: 21px; width: 173px" /></td>
                        </tr>
                        <%
                            }
                        %>--%>

                    <%--		<tr>
                                <td align="right">用户使用的ip地址:</td>
                                <td><input type="text" name="ip_add" id="ip_add" onblur="ipValidate('ip_add')" value="192.168.1.110" style="height: 21px; width: 173px" /></td>
                                <td style="text-align: left; font-size: small;" id="ip_add_Html"><span style="color: red">*请输入ip地址</span></td>
                            </tr>--%>
                    <%--<%
                        if (taiwanUser == null || !taiwanUser.equals("on")) {
                    %>
                        <!--新增dept-->
                        <c:if test="${sessionScope.user_more_dept == 'on'}">
                            <c:forEach items="${subjectList}" var="subject">
                                <tr>
                                    <td align="right">${subject.subjectName}是否分部门:</td>
                                    <td>
                                        <select class="easyui-combobox" name="isDept_add${subject.id}" id="add_idDept${subject.id}" editable=false style="height: 21px; width: 173px">
                                            <option value="" selected="selected">---请选择是否分部门---</option>
                                            <option value="Y">分部门</option>
                                            <option value="N">不分部门</option>
                                        </select>
                                    </td>
                                </tr>
                            </c:forEach>
                        </c:if>
                        <c:if test="${sessionScope.user_more_dept != 'on'}">
                            <tr>
                                <td align="right">是否分部门:</td>
                                <td>
                                    <select class="easyui-combobox" name="isDept_add"
                                            id="isDept_add1" editable=false
                                            style="height: 21px; width: 173px" data-options="onSelect:function(record){isDeptValidate('isDept_add1');}">
                                        <option value="" selected="selected">---请选择是否分部门---</option>
                                        <option value="Y">分部门</option>
                                        <option value="N">不分部门</option>
                                    </select></td>
                                <td style="text-align: left; font-size: small;" id="isDept_add1_Html"><span style="color: red">*请选择是否分部门</span></td>
                            </tr>
                        </c:if>
                    <%
                        }else{
                    %>
                        <tr>
                            <td align="right">是否多分行:</td>
                            <td>
                                <select class="easyui-combobox" name="isDept_add"
                                        id="isDept_add2" editable=false
                                        style="height: 21px; width: 173px" data-options="onSelect:function(record){isDeptValidate('isDept_add2');}">
                                    <option value="" selected="selected">---请选择是否多分行---</option>
                                    <option value="Y">多分行</option>
                                    <option value="N">不多分行</option>
                                </select></td>
                            <td style="text-align: left; font-size: small;" id="isDept_add2_Html"><span style="color: red">*请选择是否多分行</span></td>
                        </tr>
                    <%
                        }
                    %>--%>

                </table>
            </div>
        </form>
    </div>
</div>


<!-- 修改用户dialog -->
<div style="visibility: hidden;">
    <div id="editDialog" class="easyui-dialog" title="修改用户"
         data-options="iconCls:'icon-save',toolbar:'tbForEditDialog'"
         style="width: 900px; height: 460px; align-items: center;">
        <!--   新增对话框的工具栏  -->
        <div id="tbForEditDialog"
             style="padding-left: 30px; padding-top: 10px">
            <%
                if (taiwanUser != null && "on".equals(taiwanUser)) {
            %>
            <a id="editButtonId" class="easyui-linkbutton" data-options="iconCls:'icon-save'"
               onclick="saveForEditDialog(2)">保存</a>&nbsp;&nbsp;
            <a class="easyui-linkbutton" data-options="iconCls:'icon-undo'"
               onclick="resetForEdit(2)">重置</a>
            <%
            } else if (waihuiUser != null && "on".equals(waihuiUser)) {
            %>
            <a id="editButtonId" class="easyui-linkbutton" data-options="iconCls:'icon-save'"
               onclick="saveForEditDialog(3)">保存</a>&nbsp;&nbsp;
            <a class="easyui-linkbutton" data-options="iconCls:'icon-undo'"
               onclick="resetForEdit(3)">重置</a>
            <%
            } else {
            %>
            <a id="editButtonId" class="easyui-linkbutton" data-options="iconCls:'icon-save'"
               onclick="saveForEditDialog(1)">保存</a>&nbsp;&nbsp;
            <a class="easyui-linkbutton" data-options="iconCls:'icon-undo'"
               onclick="resetForEdit(1)">重置</a>
            <%
                }
            %>
        </div>

        <!-- 信息录入 -->
        <form id="formForEditUser" method="post">
            <div style="padding-top: 20px">
                <table style="padding-left: 30px">
                    <input type="hidden" name="randSession" value="<%=request.getSession().getAttribute("authId")%>"/>
                    <input type="hidden" name="isEditLoginId" id="isEditLoginId"/>
                    <tr hidden="true">
                        <input type="hidden" name="editId" id="editId"/>
                    </tr>
                    <tr>
                        <td align="right">登录账号:</td>
                        <% if (!Constants.BX_SYN_USER_ON.equals(bxSyn)) { %>
                        <td><input type="text" name="loginId_edit"
                                   id="loginId_edit" onblur="loginIdValidate('loginId_edit')"
                                   style="height: 21px; width: 173px"/></td>
                        <td style="text-align: left; font-size: small;"
                            id="loginId_edit_Html"><span style="color: red">*
									数字、字母、下划线或中文组合,长度不超过20</span></td>
                        <% } else { %>
                        <td><input type="text" name="loginId_edit"
                                   id="loginId_edit" onblur="loginIdValidate('loginId_edit')"
                                   style="height: 21px; width: 173px" readonly="true"/></td>
                        <% } %>
                    </tr>


                    <tr>
                        <td align="right">用户英文名:</td>
                        <td><input type="text" name="userEname_edit"
                                   id="userEname_edit" onblur="userEnameValidate('userEname_edit')"
                                   style="height: 21px; width: 173px"/></td>
                        <td style="text-align: left; font-size: small;"
                            id="userEname_edit_Html"><span style="color: red">*
									字母,长度不超过20</span></td>
                    </tr>

                    <tr>
                        <td align="right">用户中文名:</td>
                        <td><input type="text" name="userCname_edit"
                                   id="userCname_edit" onblur="userCnameValidate('userCname_edit')"
                                   style="height: 21px; width: 173px"/></td>
                        <td style="text-align: left; font-size: small;"
                            id="userCname_edit_Html"><span style="color: red">*
									中文,长度不超过10</span></td>
                    </tr>

                    <!-- <tr>
                 <td align="right">密码:</td>
                 <td><input class="easyui-textbox" name="password_add" id="password_add" missingMessage="密码不能为空" data-options="events:{blur:function(){passwordValidate('password_add')}}" style="height: 32px;width: 173px"/></td>
                 <td style="text-align: left;font-size: small;" id="password_add_Html"><span style="color: red">* 字母、数字,长度不超过10</span></td>
               </tr> -->

                    <%--<c:if test="${sessionScope.user_more_org != 'on'}">
                        <tr>
                            <td align="right">机构代码:</td>
                            <td><select class="easyui-combobox" name="orgId_edit"
                                        id="orgId_edit" editable=false style="height: 21px; width: 173px">
                                <c:forEach items="${orgList}" var="ol">
                                    <option value="${ol.orgId}">${ol.orgId}-${ol.orgName}</option>
                                </c:forEach>
                            </select>
                            </td>
                        </tr>
                    </c:if>--%>
                    <%--<c:if test="${sessionScope.user_more_org == 'on'}">
                        <c:forEach items="${subjectList}" var="subject">
                            <tr>
                                <td align="right">${subject.subjectName}机构代码:</td>
                                <td>
                                    <select class="easyui-combobox" name="orgId_edit${subject.id}" id="${subject.id}" editable=false style="height: 21px; width: 173px">
                                        <option value="" selected="selected">---请选择机构代码---</option>
                                        <c:forEach items="${orgList}" var="ol">
                                            <option value="${ol.orgId}">${ol.orgId}-${ol.orgName}</option>
                                        </c:forEach>
                                    </select>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
--%>
                    <tr>
                        <%
                            if (taiwanUser == null || !taiwanUser.equals("on")) {
                        %>
                        <td align="right">部门名称:</td>
                        <td><select class="easyui-combobox" name="departId_edit"
                                    id="departId_edit1" editable=false
                                    style="height: 21px; width: 173px"
                                    data-options="onSelect:function(record){departmentValidate('departId_edit1');}">
                            <option value="" selected="selected">---请选择部门---</option>
                            <c:forEach items="${departmentList}" var="dl">
                                <option value="${dl.departmentId}">${dl.departmentName}</option>
                            </c:forEach>
                        </select></td>
                        <td style="text-align: left; font-size: small;" id="departId_edit1_Html"><span
                                style="color: red">*请选择部门</span></td>
                        <%
                        } else {
                        %>
                        <td align="right">分行部门名称:</td>
                        <td><select class="easyui-combobox" name="departId_edit"
                                    id="departId_edit2" editable=false
                                    style="height: 21px; width: 173px"
                                    data-options="onSelect:function(record){departmentValidate('departId_edit2');}">
                            <option value="" selected="selected">---请选择分行部门---</option>
                            <c:forEach items="${departmentList}" var="dl">
                                <option value="${dl.departmentId}">${dl.departmentName}</option>
                            </c:forEach>
                        </select></td>
                        <td style="text-align: left; font-size: small;" id="departId_edit2_Html"><span
                                style="color: red">*请选择分行部门</span></td>
                        <%
                            }
                        %>
                    </tr>

                    <%--<tr>
                        <td align="right">联系电话:</td>
                        <td><input type="text" name="tel_edit"
                            id="tel_edit" style="height: 21px; width: 173px" /></td>
                    </tr>

                    <tr>
                        <td align="right">移动电话:</td>
                        <td><input type="text" name="mobile_edit"
                            id="mobile_edit" style="height: 21px; width: 173px" /></td>
                    </tr>

                    <tr>
                        <td align="right">地址:</td>
                        <td><input type="text" name="address_edit"
                            id="address_edit" style="height: 21px; width: 173px" /></td>
                    </tr>

                    <tr>
                        <td align="right">邮箱:</td>
                        <%
                            if (taiwanUser != null && "on".equals(taiwanUser)) {
                        %>
                        <td><input type="text" name="email_edit"
                                   id="email_edit2" style="height: 21px; width: 173px" onblur="emailValidate('email_edit2')"/></td>
                        <td style="text-align: left; font-size: small;" id="email_edit2_Html"><span style="color: red">*请输入邮箱</span></td>
                        <%
                            }else if(waihuiUser != null && "on".equals(waihuiUser)){
                        %>
                        <td><input type="text" name="email_edit"
                                   id="email_edit3" style="height: 21px; width: 173px" onblur="emailValidate('email_edit3')"/></td>
                        <td style="text-align: left; font-size: small;" id="email_edit3_Html"><span style="color: red">*请输入邮箱</span></td>
                        <%
                            }else {
                        %>
                        <td><input type="text" name="email_edit"
                                   id="email_edit1" style="height: 21px; width: 173px" /></td>
                        <%
                            }
                        %>
                    </tr>
--%>
                    <%--<tr>
                        <td align="right">用户使用的ip地址:</td>
                        <td><input type="text" name="ip_edit"id="ip_edit" onblur="ipValidate('ip_edit')"style="height: 21px; width: 173px" /></td>
                        <td style="text-align: left; font-size: small;" id="ip_edit_Html"><span style="color: red">*请输入ip地址</span></td>
                    </tr>
                    <%
                        if (taiwanUser == null || !taiwanUser.equals("on")) {
                    %>

                    <c:if test="${sessionScope.user_more_dept == 'on'}">
                        <c:forEach items="${subjectList}" var="subject">
                            <tr>
                                <td align="right">${subject.subjectName}是否分部门:</td>
                                <td>
                                    <select class="easyui-combobox" name="isDept_edit${subject.id}" id="isDept_edit${subject.id}" editable=false style="height: 21px; width: 173px" >
                                        <option value="" selected="selected">---请选择是否分部门---</option>
                                        <option value="Y">分部门</option>
                                        <option value="N">不分部门</option>
                                    </select>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:if>
                    <c:if test="${sessionScope.user_more_dept != 'on'}">
                        <tr>
                            <td align="right">是否分部门:</td>
                            <td><select class="easyui-combobox" name="isDept_edit${subject.id}"
                                        id="isDept_edit1" editable=false
                                        style="height: 21px; width: 173px" data-options="onSelect:function(record){isDeptValidate('isDept_edit1');}">
                                <option value="" selected="selected">---请选择是否分部门---</option>
                                <option value="Y">分部门</option>
                                <option value="N">不分部门</option>
                            </select></td>
                            <td style="text-align: left; font-size: small;" id="isDept_edit1_Html"><span style="color: red">*请选择是否分部门</span></td>
                        </tr>
                    </c:if>
                    <%
                    }else{
                    %>
                        <tr>
                            <td align="right">是否多分行:</td>
                            <td>
                                <select class="easyui-combobox" name="isDept_edit${subject.id}"
                                        id="isDept_edit2" editable=false
                                        style="height: 21px; width: 173px" data-options="onSelect:function(record){isDeptValidate('isDept_edit2');}">
                                    <option value="" selected="selected">---请选择是否多分行---</option>
                                    <option value="Y">多分行</option>
                                    <option value="N">不多分行</option>
                                </select></td>
                            <td style="text-align: left; font-size: small;" id="isDept_edit2_Html"><span style="color: red">*请选择是否多分行</span></td>
                        </tr>
                    <%
                        }
                    %>--%>
                </table>
            </div>
        </form>
    </div>
</div>

<!-- 导入文件dialog -->
<div style="visibility: hidden;">
    <div id="importFileDialog" class="easyui-dialog"
         style="width: 500px; height: 220px; padding-left: 30px" title="导入文件">
        <h4>附件上传：</h4>
        <form enctype="multipart/form-data" id="importform">
            <table id=test border="0">
                <tr>
                    <td><input type="file" name="file_info" id="file_info" size="60" accept="xsl">&nbsp;</td>
                </tr>
            </table>
            <button onclick="addline();">单击此处添加更多附件</button>
            <br> <input type="button" value="提交" onClick="uploadFile()">
        </form>
    </div>
</div>


<!-- 用户资源分配 -->
<div style="visibility: hidden;">
    <div id="userResourDialog" class="easyui-dialog" title="报表管理" style="width: 1200px; height:500px"
         data-options="iconCls:'icon-save',toolbar:'#tbForRoleResourceDialog'">
        <div style="margin:10px 0;"></div>
        <div class="easyui-tabs" style="width:1170px;height:400px;margin-left:10px">

            <div title="报表权限" style="margin-top:10px;margin-left:10px">
                <table id="reportInfo" class="easyui-datagrid" style="width:1150px;height:340px"
                       data-options="checkOnSelect:true,autoRowHeight:false,pagination:true,rownumbers:true,idField:'id', pageSize:100,pageList:[20]">
                    <thead>
                    <tr>
                        <%--								<th field="ck" checkbox="true"></th>--%>
                        <th data-options="field:'id',width:100,align:'center',hidden:true">ID</th>
                        <th data-options="field:'code',width:200,align:'center'">报表代码</th>
                        <th data-options="field:'name',width:245,align:'center'">报表名称</th>
                        <th data-options="field:'uploadFrequency',width:245,align:'center'">上传频率</th>
                        <th data-options="field:'reportStatus',width:245,align:'center'">报表状态</th>
                      <%--  <th data-options="field:'instruction',width:245,align:'center'">备注</th>--%>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>

<!-- 导入excel文档后显示错误信息 -->

<script type="text/javascript">
    var loginIdResult;
    var userEnameResult;
    var userCnameResult;
    var departmentResult;
    var passwordReslt;
    var ipResult;
    var isdeptmentResult;
    var emailResult;

    function loginIdValidate(textId) {
        loginIdResult = loginIdCheck(textId);
    }

    function userEnameValidate(textId) {
        userEnameResult = userEnameCheck(textId);
    }

    function userCnameValidate(textId) {
        userCnameResult = userCnameCheck(textId);
    }

    function emailValidate(textId) {
        emailResult = emailCheck2(textId);
    }

    function departmentValidate(textId) {

        departmentResult = departmentCheck(textId);
    }

    function isDeptValidate(textId) {
        /*if(textId.substring(textId.length-1)=="1"){
            isdeptmentResult = isdeptCheck1(textId);
        }else{
            isdeptmentResult = isdeptCheck2(textId);
        }*/
    }

    function ipValidate(textId) {
        //ipResult = ipCheck(textId);
    }

    /* function passwordValidate(textId){
        passwordReslt = passwordCheck(textId);
    } */

    var loginIdBackUp;//保存要修改的用户的登录账号

    $(function () {
        $('#addDialog').dialog('close');
        $('#editDialog').dialog('close');
        $('#importFileDialog').dialog('close');
        $('#userResourDialog').dialog('close');
        $('#reportInfo').datagrid({loadFilter: pagerFilter, fitColumns: true});//为手工报表添加分页

        $('#dg1').datagrid({loadFilter: pagerFilter, fit: true, fitColumns: true,});//.datagrid('loadData', getData());
        $('.datagrid-header-check').find('input').attr('style', 'display:none');

        //双击查看修改明细
        $('#dg1').datagrid({
            onDblClickRow: function (rowIndex, rowData) {
                if (rowData.description.trim() != "") {
                    $.messager.alert('修改明细', rowData.description, 'info');
                } else if (rowData.startDate == "") {
                    $.messager.alert('修改明细', '该用户未做过修改', 'info');
                } else {
                    $.messager.alert('修改明细', '该用户上次修改未填写修改内容', 'info');
                }
            }
        });
        $('#dg1').datagrid('getPager').pagination({ //设置分页功能栏
            //分页功能可以通过Pagination的事件调用后台分页功能来实现
            onRefresh: function () {
                selectRecordByName();
            }
        });
    });

    function pagerFilter(data) {
        if (typeof data.length == 'number'
            && typeof data.splice == 'function') { // is array
            data = {
                total: data.length,
                rows: data
            }
        }
        var dg = $(this);
        var opts = dg.datagrid('options');
        var pager = dg.datagrid('getPager');
        pager.pagination({
            onSelectPage: function (pageNum, pageSize) {
                opts.pageNumber = pageNum;
                opts.pageSize = pageSize;
                pager.pagination('refresh', {
                    pageNumber: pageNum,
                    pageSize: pageSize
                });
                dg.datagrid('loadData', data);
            }
        });
        if (!data.originalRows) {
            data.originalRows = (data.rows);
        }
        var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
        var end = start + parseInt(opts.pageSize);
        data.rows = (data.originalRows.slice(start, end));
        return data;
    }


    function isdeptCheck1(textId) {
        var isDept = $("#" + textId).combobox('getValue');
        if (isDept.length != 0) {
            $("#" + textId + "_Html").html('');
            $("#" + textId + "_Html").html('<span style="color: green">*</span>');
            return true;
        } else {
            $("#" + textId + "_Html").html('');
            $("#" + textId + "_Html").html('<span style="color: red">*请选择是否分部门</span>');
            return false;
        }
    }

    function isdeptCheck2(textId) {
        var isDept = $("#" + textId).combobox('getValue');
        if (isDept.length != 0) {
            $("#" + textId + "_Html").html('');
            $("#" + textId + "_Html").html('<span style="color: green">*</span>');
            return true;
        } else {
            $("#" + textId + "_Html").html('');
            $("#" + textId + "_Html").html('<span style="color: red">*请选择是否多分行</span>');
            return false;
        }
    }

    //同意申请
    function agreenApply() {
        var row = $("#dg1").datagrid('getSelected'); //获取选中行对象
        var randSession = "${authId}"
        if (row != null) {
            var applyname = row.handlename;
            if (applyname.substring(0, 2) == '申请') {
                $.ajax({
                    url: 'agreenApply',
                    type: 'POST', //GET
                    async: true, //或false,是否异步
                    contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                    data: {"id": row.id, "applyname": applyname, "randSession": randSession},
                    dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                    success: function (data) {
                        if (applyname == '申请新增') {
                            if (data == '1') {
                                $.messager.alert('', '同意新增成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '同意新增失败', 'error');
                            }
                        } else if (applyname == '申请修改') {
                            if (data == '1') {
                                $.messager.alert('', '同意修改成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '同意修改失败', 'error');
                            }
                        } else if (applyname == '申请重置密码') {
                            if (data == '1') {
                                $.messager.alert('', '同意重置密码成功,该用户密码已重置为初始密码', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '同意重置密码失败', 'error');
                            }
                        } else if (applyname == '申请锁定') {
                            if (data == '1') {
                                $.messager.alert('', '同意锁定成功,该用户已被锁定', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '同意锁定失败', 'error');
                            }
                        } else if (applyname == '申请解锁') {
                            if (data == '1') {
                                $.messager.alert('', '同意解锁成功,该用户已被解锁', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '同意解锁失败', 'error');
                            }
                        } else {

                        }
                    }
                });
            } else {
                $.messager.alert('操作提示', '请选择一条申请的数据', 'info');
            }
        } else {
            $.messager.alert('操作提示', '请选择一条申请的数据', 'info');
        }
    }


    //拒绝申请
    function refuseApply() {
        var row = $("#dg1").datagrid('getSelected'); //获取选中行对象
        var randSession = "${authId}"
        if (row != null) {
            var applyname = row.handlename;
            if (applyname.substring(0, 2) == '申请') {
                $.ajax({
                    url: 'refuseApply',
                    type: 'POST', //GET
                    async: true, //或false,是否异步
                    contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                    data: {"id": row.id, "applyname": applyname, "randSession": randSession},
                    dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                    success: function (data) {
                        if (applyname == '申请新增') {
                            if (data == '1') {
                                $.messager.alert('', '拒绝新增成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '拒绝新增失败', 'error');
                            }
                        } else if (applyname == '申请修改') {
                            if (data == '1') {
                                $.messager.alert('', '拒绝修改成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '拒绝修改失败', 'error');
                            }
                        } else if (applyname == '申请重置密码') {
                            if (data == '1') {
                                $.messager.alert('', '拒绝重置密码成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '拒绝重置密码失败', 'error');
                            }
                        } else if (applyname == '申请锁定') {
                            if (data == '1') {
                                $.messager.alert('', '拒绝锁定成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '拒绝锁定失败', 'error');
                            }
                        } else if (applyname == '申请解锁') {
                            if (data == '1') {
                                $.messager.alert('', '拒绝解锁成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '拒绝解锁失败', 'error');
                            }
                        } else {

                        }
                    }
                });
            } else {
                $.messager.alert('操作提示', '请选择一条申请的数据', 'info');
            }
        } else {
            $.messager.alert('操作提示', '请选择一条申请的数据', 'info');
        }
    }

    //点击查询按钮
    function selectRecordByName() {
        var userCname = $("#userCname").val();
        var randSession = "${authId}"
        window.location.href = 'getSys_user?userCname=' + encodeURIComponent(userCname) + "&randSession=" + randSession;
    }

    //点击新增用户按钮
    function addUser(num) {
        //验证文本框
        loginIdValidate('loginId_add');
        userEnameValidate('userEname_add');
        userCnameValidate('userCname_add');
        if (num == 3) {
            num = 1;
            departmentValidate('departId_add' + num);
            <c:if test="${sessionScope.user_more_dept != 'on'}">
            isDeptValidate('isDept_add' + num);
            </c:if>
            num = 3;
        }
        ipValidate('ip_add');
        if (num == 2) {
            emailValidate('email_add2');
        } else if (num == 3) {
            num = 2;
            emailValidate('email_add3');
            num = 3;
        }
        $('#addDialog').dialog('open'); //打开对话框
        $('#addDialog').dialog({
            modal: true
        });

        // 是否显示ip输入框，有配置则隐藏
        var showUserIp = "<%=session.getAttribute("showUserIp")%>";
        if (showUserIp != '') {
            $('#ip_add').parent().parent().attr('style', 'display:none');
        }
    }

    //点击修改用户按钮
    function editUser(num) {
        var row = $("#dg1").datagrid('getSelected'); //获取选中行对象
        //console.log(1);
        row.handlename = "同意修改";
        if (row != null) { //如果选中
            if (row.handlename == '同意修改') {
                //为修改dialog框中的文本框赋值
                //console.log(2);
                document.getElementById("editId").value = row.id;
                loginIdBackUp = row.loginId;
                $("#loginId_edit").val(row.loginId);
                $("#userEname_edit").val(row.userEname);
                $("#userCname_edit").val(row.userCname);
                <c:if test="${sessionScope.user_more_org != 'on'}">
                $("#orgId_edit").combobox('setValue', row.orgId);
                </c:if>

                let endDateInfo = row.endDate;
                let s = 0;
                <c:if test="${sessionScope.user_more_org == 'on'}">
                if (row.endDate.trim() != "") {
                    var orgids = eval("(" + row.endDate + ")");
                    <c:forEach items="${subjectList}" var="subject">
                    var tempOId = orgids['${subject.id}'];
                    <c:forEach items="${orgList}" var="orgid">
                    if (tempOId == '${orgid.orgId}') {
                        let subjectId = '${subject.id}';
                        $("#" + subjectId).combobox('select', tempOId);
                        s = 1;
                    }
                    </c:forEach>
                    if (s == 0) {
                        let subjectId = '${subject.id}';
                        $("#" + subjectId).combobox('select', '');
                    }
                    s = 0;
                    </c:forEach>
                } else {
                    <c:forEach items="${subjectList}" var="subject">
                    $("#${subject.id}").combobox('select', '');
                    </c:forEach>
                }
                </c:if>
                if (num == 2) {
                    $("#departId_edit" + num).combobox('setValue', row.departId);

                } else if (num == 3) {
                    num = 1;
                    $("#departId_edit" + num).combobox('setValue', row.departId);
                    num = 3;
                } else {
                    $("#departId_edit" + num).combobox('setValue', row.departId);
                }
                $("#tel_edit").val(row.tel);
                $("#mobile_edit").val(row.mobile);
                $("#address_edit").val(row.address);
                $("#email_edit" + num).val(row.email);
                $("#ip_edit").val(row.ip);

                <c:if test="${sessionScope.user_more_dept != 'on'}">
                if (num == 2) {
                    $("#isDept_edit" + num).combobox('setValue', row.isDeptValue);

                } else if (num == 3) {
                    num = 1;
                    $("#isDept_edit" + num).combobox('setValue', row.isDeptValue);
                    num = 3;
                } else {
                    $("#isDept_edit" + num).combobox('setValue', row.isDeptValue);
                }
                </c:if>

                let systemDept = row.systemDept;
                //console.log("systemDept:"+systemDept);
                //console.log(4);
                <c:if test="${sessionScope.user_more_dept == 'on'}">
                if (systemDept != "") {
                    if (num == 3) {
                        num = 1;
                        var depts = eval("(" + row.systemDept + ")");
                        <c:forEach items="${subjectList}" var="subject">
                        var tempOId = depts['${subject.id}'];
                        if ("" != tempOId) {
                            $("#isDept_edit${subject.id}").combobox('select', tempOId);
                        }
                        num = 3;
                    }
                    </c:forEach>
                } else {
                    <c:forEach items="${subjectList}" var="subject">
                    $("#isDept_edit${subject.id}").combobox('select', 'Y');
                    </c:forEach>
                }
                </c:if>
                <%--if (systemDept != "") {--%>
                <%--	<c:if test="${sessionScope.user_more_dept == 'on'}">--%>
                <%--	//console.log(5);--%>
                <%--	if(systemDept.trim!= ""){--%>
                <%--		var depts =  eval("("+row.systemDept+")");--%>

                <%--		<c:forEach items="${subjectList}" var="subject">--%>
                <%--		var tempOId = depts['${subject.id}'];--%>
                <%--		if ("" != tempOId) {--%>
                <%--			//console.log("tempOld:"+tempOId);--%>
                <%--			//console.log("#isDept_edit${subject.id}");--%>
                <%--			$("#isDept_edit${subject.id}").combobox('select', tempOId);--%>
                <%--		}--%>
                <%--		</c:forEach>--%>
                <%--	}--%>
                <%--	</c:if>--%>
                <%--}--%>

                //验证文本框
                loginIdValidate('loginId_edit');
                userEnameValidate('userEname_edit');
                userCnameValidate('userCname_edit');

                if (num == 3) {
                    num = 1;
                    departmentValidate('departId_edit' + num);
                    <c:if test="${sessionScope.user_more_dept != 'on'}">
                    isDeptValidate('isDept_edit' + num);
                    </c:if>
                    num = 3;
                } else if (num == 2) {
                    departmentValidate('departId_edit' + num);
                    <c:if test="${sessionScope.user_more_dept != 'on'}">
                    isDeptValidate('isDept_edit' + num);
                    </c:if>

                } else {
                    departmentValidate('departId_edit' + num);
                    <c:if test="${sessionScope.user_more_dept != 'on'}">
                    isDeptValidate('isDept_edit' + num);
                    </c:if>
                }
                ipValidate('ip_edit');
                if (num == 2) {
                    emailValidate('email_edit2');
                } else if (num == 3) {
                    num = 2;
                    emailValidate('email_edit3');
                    num = 3;
                }
                $('#editDialog').dialog('open');
                $('#editDialog').dialog({
                    modal: true
                });

                // 是否显示ip输入框，有配置则隐藏
                var showUserIp = "<%=session.getAttribute("showUserIp")%>";
                if (showUserIp != '') {
                    $('#ip_edit').parent().parent().attr('style', 'display:none');
                }
            } else if (row.handlename == ' ') {
                $.messager.prompt('操作提示', '请填写修改明细', function (r) {
                    if (r) {
                        $.ajax({
                            url: 'applyEdit',
                            type: 'POST', //GET
                            async: true, //或false,是否异步
                            contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                            data: {"id": row.id, "desc": r, "randSession": "${authId}"},
                            dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                            success: function (data) {
                                if (data == '1') {
                                    $.messager.alert('', '申请修改成功', 'info', function (r) {
                                        window.location.href = "sys_user";
                                    });
                                } else {
                                    $.messager.alert('操作提示', '申请修改失败', 'error');
                                }
                            }
                        });
                    }
                })
            } else {
                $.messager.alert('操作提示', '请选择一条操作名为空或者同意修改的数据', 'info');
            }
        } else {
            $.messager.alert('操作提示', '请选择一条操作名为空或者同意修改的数据', 'info');
        }
    }

    //点击重置用户密码按钮
    function editPasswordUser() {
        var row = $("#dg1").datagrid('getSelected'); //获取选中行对象
        var randSession = "${authId}"
        if (row != null) { //如果选中
            $.messager.confirm('操作提示', '确定要重置密码吗？', function (r) {
                if (r) {
                    $.ajax({
                        url: 'applyReaptPwd',
                        type: 'GET', //GET
                        async: true, //或false,是否异步
                        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                        data: {"id": row.id, "pwd": "12345678", "randSession": randSession},
                        dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                        success: function (data) {
                            if (data == '1') {
                                $.messager.alert('', '重置密码成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '重置密码失败', 'error');
                            }
                        }
                    })
                }
            });
        } else {
            $.messager.alert('操作提示', '请选择数据', 'info');
        }
    }

    //点击删除用户按钮
    function remove() {
        var row = $("#dg1").datagrid('getSelected'); //获取选中行对象
        var randSession = "${authId}"
        if (row != null) { //如果选中
            if (row.loginId == "admin") {
                $.messager.alert('操作提示', '不能删除管理员账号', 'error');
            } else {
                $.messager.alert('操作提示', '是否要将此用户删除,如果删除，此用户将不能再使用', 'warning', function (r) {
                    $.ajax({
                        url: 'deleteSys_User',
                        type: 'POST', //GET
                        async: true, //或false,是否异步
                        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                        //TODO zjf
                        data: {"id": row.id, "loginId": row.loginId, "randSession": randSession},
                        dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                        success: function (data) {
                            if (data.result == '1') { //如果返回1，删除成功
                                $.messager.alert('', '删除用户成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else { //否则删除失败
                                $.messager.alert('操作提示', '此用户删除失败', 'error');
                            }
                        }
                    })
                });
            }
        } else {
            $.messager.alert('操作提示', '请选择一条数据删除', 'info');
        }
    }

    //点击导出按钮
    function exportExcel() {
        $.messager.confirm('操作提示', '确认将数据导出到Excel表格吗？', function (r) {
            if (r) {
                window.location.href = "exportExcelSys_User";
            }
        });
    }

    //===============与导入相关的js============================
    function importExcel() {
        $('#importFileDialog').dialog('open');
        $('#importFileDialog').dialog({
            modal: true
        });
    }

    function addline() {
        newline = document.all.test.insertRow();
        newline.insertCell().innerHTML = "<input type='file' name='file_info' size='60'>&nbsp;"
            + "<button onclick='javascript:removeline(this)'>移除</button>";
    }

    function removeline(obj) {
        var objSourceRow = obj.parentNode.parentNode;
        var objTable = obj.parentNode.parentNode.parentNode.parentNode;
        objTable.lastChild.removeChild(objSourceRow);
    }

    function uploadFile() {
        $.messager
            .confirm(
                '操作提示',
                '确认要导入Excel表格吗？',
                function (r) {
                    if (r) {
                        var fd = new FormData();
                        fd
                            .append(
                                "fileToUpload",
                                document
                                    .getElementById('file_info').files[0]);
                        var filesize = document
                            .getElementById('file_info').files[0].size;
                        var filetype = document
                            .getElementById('file_info').files[0].type;
                        if (filetype != "application/vnd.ms-excel") {
                            $('#importFileDialog').dialog('close');
                            $.messager.alert({
                                title: "错误",
                                msg: "您上传的文件类型有误，请重新上传!",
                                icon: "error"
                            });

                            return false;
                        }
                        if (filesize > 1048576) {
                            $('#importFileDialog').dialog('close');
                            $.messager.alert('错误',
                                '您上传的文件大小超出2MB请重新上传!',
                                "warning");
                            return false;
                        }
                        var xhr = new XMLHttpRequest();
                        xhr.open("POST", "importExcelSys_User");
                        console.info(fd.polyfill);
                        //由于IE8不兼容FromDate对象所以使用ployfill来判断
                        if (fd.polyfill) {
                            xhr.setRequestHeader("Content-Type",
                                "multipart/form-data; boundary="
                                + fd.boundary)
                            // formData.toString() returns Promise
                            fd.toString().then(function (data) {
                                xhr.send(data);
                            })
                        } else {
                            // normal way
                            xhr.send(fd);
                        }
                        xhr.onreadystatechange = function () {

                            if (xhr.readyState == 4) {
                                if (xhr.status == 200) {
                                    var info = xhr.responseText;
                                    $('#importFileDialog').dialog(
                                        'close');
                                    $.messager
                                        .alert({
                                            title: "提示",
                                            msg: info
                                                .substring(
                                                    1,
                                                    info.length - 1),
                                            icon: "info",
                                            width: 500,
                                            fn: function () {
                                                window.location.href = "sys_user";
                                            }
                                        });

                                } else {
                                    $('#importFileDialog').dialog(
                                        'close');
                                    var info = xhr.responseText;
                                    $.messager
                                        .alert(
                                            "提示",
                                            info
                                                .substring(
                                                    1,
                                                    info.length - 1),
                                            "info");
                                }
                            }
                        };
                    } else {
                        $('#importFileDialog').dialog('close');
                    }
                })
    }

    /************************************************************************************************************************************/
    /************************************************************************************************************************************/
    /************************************************************************************************************************************/

    function resetForAdd(num) {
        $("#loginId_add").val('');
        $("#userEname_add").val('');
        $("#userCname_add").val('');
        <c:if test="${sessionScope.user_more_org != 'on'}">
        $("#orgId_add").combobox('setValue', '');
        </c:if>
        <c:if test="${sessionScope.user_more_org == 'on'}">
        <c:forEach items="${subjectList}" var="subject">
        $("#add_orgId${subject.id}").combobox('setValue', '');
        </c:forEach>
        </c:if>
        $("#departId_add" + num).combobox('setValue', '');
        $("#tel_add").val('');
        $("#mobile_add").val('');
        $("#address_add").val('');
        $("#email_add" + num).val('');
        $("#ip_add").val('');
        <c:if test="${sessionScope.user_more_dept != 'on'}">
        $("#isDept_add").combobox('setValue', '');
        </c:if>
        <c:if test="${sessionScope.user_more_dept == 'on'}">
        <c:forEach items="${subjectList}" var="subject">
        $("#add_idDept${subject.id}").combobox('setValue', 'Y');
        </c:forEach>
        </c:if>

    }

    function resetForEdit(num) {
        var row = $("#dg1").datagrid('getSelected');
        if (row.handlename == '同意修改') {
            //为修改dialog框中的文本框赋值
            //console.log(2);
            document.getElementById("editId").value = row.id;
            loginIdBackUp = row.loginId;
            $("#loginId_edit").val(row.loginId);
            $("#userEname_edit").val(row.userEname);
            $("#userCname_edit").val(row.userCname);
            <c:if test="${sessionScope.user_more_org != 'on'}">
            $("#orgId_edit").combobox('setValue', row.orgId);
            </c:if>

            let endDateInfo = row.endDate;
            let s = 0;
            <c:if test="${sessionScope.user_more_org == 'on'}">
            if (row.endDate.trim() != "") {
                var orgids = eval("(" + row.endDate + ")");
                <c:forEach items="${subjectList}" var="subject">
                var tempOId = orgids['${subject.id}'];
                <c:forEach items="${orgList}" var="orgid">
                if (tempOId == '${orgid.orgId}') {
                    let subjectId = '${subject.id}';
                    $("#" + subjectId).combobox('select', tempOId);
                    s = 1;
                }
                </c:forEach>
                if (s == 0) {
                    let subjectId = '${subject.id}';
                    $("#" + subjectId).combobox('select', '');
                }
                s = 0;
                </c:forEach>
            } else {
                <c:forEach items="${subjectList}" var="subject">
                $("#${subject.id}").combobox('select', '');
                </c:forEach>
            }
            </c:if>
            //console.log(3);
            $("#departId_edit" + num).combobox('setValue', row.departId);
            $("#tel_edit").val(row.tel);
            $("#mobile_edit").val(row.mobile);
            $("#address_edit").val(row.address);
            $("#email_edit" + num).val(row.email);
            $("#ip_edit").val(row.ip);

            <c:if test="${sessionScope.user_more_dept != 'on'}">
            $("#isDept_edit" + num).combobox('setValue', row.isDeptValue);
            </c:if>

            let systemDept = row.systemDept;
            //console.log("systemDept:"+systemDept);
            //console.log(4);
            <c:if test="${sessionScope.user_more_dept == 'on'}">
            if (systemDept != "") {
                var depts = eval("(" + row.systemDept + ")");
                <c:forEach items="${subjectList}" var="subject">
                var tempOId = depts['${subject.id}'];
                if ("" != tempOId) {
                    $("#isDept_edit${subject.id}").combobox('select', tempOId);
                }
                </c:forEach>
            } else {
                <c:forEach items="${subjectList}" var="subject">
                $("#isDept_edit${subject.id}").combobox('select', 'Y');
                </c:forEach>
            }
            </c:if>
            <%--if (systemDept != "") {--%>
            <%--	<c:if test="${sessionScope.user_more_dept == 'on'}">--%>
            <%--	//console.log(5);--%>
            <%--	if(systemDept.trim!= ""){--%>
            <%--		var depts =  eval("("+row.systemDept+")");--%>

            <%--		<c:forEach items="${subjectList}" var="subject">--%>
            <%--		var tempOId = depts['${subject.id}'];--%>
            <%--		if ("" != tempOId) {--%>
            <%--			//console.log("tempOld:"+tempOId);--%>
            <%--			//console.log("#isDept_edit${subject.id}");--%>
            <%--			$("#isDept_edit${subject.id}").combobox('select', tempOId);--%>
            <%--		}--%>
            <%--		</c:forEach>--%>
            <%--	}--%>
            <%--	</c:if>--%>
            <%--}--%>

            //验证文本框
            loginIdValidate('loginId_edit');
            userEnameValidate('userEname_edit');
            userCnameValidate('userCname_edit');
            departmentValidate('departId_edit' + num);
            ipValidate('ip_edit');
            <c:if test="${sessionScope.user_more_dept != 'on'}">
            isDeptValidate('isDept_edit' + num);
            </c:if>

            $('#editDialog').dialog('open');
            $('#editDialog').dialog({
                modal: true
            });

            // 是否显示ip输入框，有配置则隐藏
            var showUserIp = "<%=session.getAttribute("showUserIp")%>";
            if (showUserIp != '') {
                $('#ip_edit').parent().parent().attr('style', 'display:none');
            }
        }
    }

    //验证密码
    function checkPassword() {
        var password = $("#password_edit").val(); //获取密码框输入的密码
        if (password.length == 0 || password == null || password == '') {
            $.messager.alert('操作提示', '请输入密码', 'info');
        }
    }

    //验证重复密码
    function checkRepeatPassword() {
        var password = $("#password_edit").val(); //获取密码框输入的密码
        var repeatPassword = $("#passwordRepeat_edit").val(); //获取重复密码框输入的密码
        if (repeatPassword.length == 0 || repeatPassword == null
            || repeatPassword == '') {
            $.messager.alert('操作提示', '请输入重复密码', 'info');
        } else if (password != repeatPassword) {
            $.messager.alert('', '两次输入的密码不一致', 'info', function (r) {
                $("#passwordRepeat_edit").val('');
            });
        }
    }

    //点击新增dialog上的保存按钮
    function saveForAddDialog(num) {
        $("#saveButtonId").linkbutton({disabled: true});
        <%--<%
        if (request.getSession().getAttribute("user_more_dept") != null && "on".equalsIgnoreCase(request.getSession().getAttribute("user_more_dept").toString())){
        %>
        isdeptmentResult = true;
        <%
        }
        %>--%>
        $("#formForAddUser").form('submit', {
            url: 'addSys_User',
            onSubmit: function () {
                if (loginIdResult == true && userEnameResult == true && userCnameResult == true && departmentResult == true /*&& ipResult == true*/) {
                    if (num == 2 && emailResult == false) {
                        $.messager.alert('操作提示', '请填写正确的用户信息！', 'info');
                        $("#saveButtonId").linkbutton({disabled: false});
                        return false;
                    } else {
                        $.messager.progress({
                            title: '请稍等',
                            msg: '正在保存用户...'
                        });
                        return true;
                    }
                } else {
                    $.messager.alert('操作提示', '请填写正确的用户信息！', 'info');
                    $("#saveButtonId").linkbutton({disabled: false});
                    return false;
                }
            },
            success: function (res) {
                let rest = JSON.parse(res);
                $.messager.progress('close');
                if (rest.result == true) {
                    $.messager.alert('操作提示', rest.message, 'info');
                    window.location.href = "sys_user";
                } else {
                    $.messager.alert('操作提示', rest.message, 'error');
                }
                $("#saveButtonId").linkbutton({disabled: false});
            }
        });
    }

    //点击修改dialog上的保存按钮
    function saveForEditDialog(num) {
        if (loginIdBackUp != $("#loginId_edit").val()) { //如果修改前的登录账号和修改后的登录账号不一致，则表示用户修改了登录账号
            document.getElementById("isEditLoginId").value = '1';
        } else {
            document.getElementById("isEditLoginId").value = '0';
        }
        <%
        if (request.getSession().getAttribute("user_more_dept") != null && "on".equalsIgnoreCase(request.getSession().getAttribute("user_more_dept").toString())){
        %>
        isdeptmentResult = true;
        <%
        }
        %>
        $("#editButtonId").linkbutton({disabled: true});
        $("#formForEditUser").form('submit', {
            url: 'editSys_User',
            onSubmit: function () {
                if (loginIdResult == true && userEnameResult == true && userCnameResult == true && departmentResult == true /*&& ipResult == true && isdeptmentResult == true*/) {
                    if (num == 2 && emailResult == false) {
                        $.messager.alert('操作提示', '请填写正确的用户信息！', 'info');
                        $("#editButtonId").linkbutton({disabled: false});
                        return false;
                    } else if (num == 3 && emailResult == false) {
                        $.messager.alert('操作提示', '请填写正确的用户信息！', 'info');
                        $("#editButtonId").linkbutton({disabled: false});
                        return false;
                    } else {

                        $.messager.progress({
                            title: '请稍等',
                            msg: '正在保存用户...'
                        });
                        return true;
                    }
                } else {
                    $.messager.alert('操作提示', '请填写正确的用户信息！', 'info');
                    $("#editButtonId").linkbutton({disabled: false});
                    return false;
                }
            },
            success: function (rest) {
                console.log(rest);
                let res = JSON.parse(rest);
                console.log(res);
                console.log(res.result);
                console.log(res.message);
                $.messager.progress('close');
                if (res.result == true) {
                    $.messager.alert('操作提示', res.message, 'info');
                    window.location.href = "sys_user";
                } else {
                    $.messager.alert('操作提示', res.message, 'error');
                }
                // if (res == '1') {
                // 	$.messager.alert('', '修改成功！', 'info', function(r) {
                // 		window.location.href = "sys_user";
                // 	});
                // } else if (res == '0') {
                // 	$.messager.alert('操作提示', '修改用户失败了', 'error');
                // } else if (res == '2'){
                // 	$.messager.alert('操作提示', '登录账号已存在', 'error');
                // } else {
                // 	$.messager.alert('操作提示','系统错误','error');
                // }
                $("#editButtonId").linkbutton({disabled: false});
            }
        });
    }


    //点击查看手工报表按钮
    function userResource() {
        var row = $("#dg1").datagrid('getSelected'); //获取选中行对象
        if (row != null) { //如果选中
            userId = row.id;
            subjectId = row.subjectId;
            $.ajax({
                url: 'queryUserReportById',
                type: 'GET', //GET
                async: true, //或false,是否异步
                contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                data: {"subjectId": subjectId, "userId": userId, "randSession": "${authId}"},
                dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                success: function (data) {
                    //显示报表权限的数据
                    var report = []
                    for (var i = 0; i < data.length; i++) {
                        report.push({
                            'id': data[i].id,
                            'subjectId': data[i].subjectId,
                            'code': data[i].code,
                            'name': data[i].name,
                            'uploadFrequency': data[i].uploadFrequency,
                            'reportStatus': data[i].reportStatus == '1' ? '上线' : '下线',
                            'instruction': data[i].instruction
                        });
                    }

                    //回显已经为角色分配好的权限
                    $('#reportInfo').datagrid('loadData', report);

                    //获取权限分配数据网格中的所有数据
                    // var reportArray = $('#reportInfo').datagrid('getRows');

                    //为权限tabs回显
                    $('#reportInfo').datagrid('unselectAll');

                    // for (var i = 0; i < userResourceList.length; i++) {
                    // 	if (userResourceList[i].resType == 'Report') {
                    // 		for (var j = 0; j < reportArray.length; j++) {
                    // 			if (userResourceList[i].resId == reportArray[j].id) {
                    // 				$('#reportInfo').datagrid('selectRow', j);
                    // 			}
                    // 		}
                    // 	}
                    // }

                }
            });

            $('#userResourDialog').dialog('open');
            $('#userResourDialog').dialog({modal: true});
        } else {
            $.messager.alert('操作提示', '请选择一条数据分配角色权限', 'info');
        }
    }


    //锁定用户与解锁用户
    function doLocked(handlename, id, isLocked) {
        if (isLocked == 'Y') { //如果该用户已锁定，则申请解锁
            if (handlename == ' ') {
                $.messager.alert('操作提示', '是否要申请解锁该用户', 'question', function (r) {
                    $.ajax({
                        url: 'applyNoLock',
                        type: 'POST', //GET
                        async: true, //或false,是否异步
                        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                        data: {"id": id, "randSession": "${authId}"},
                        dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                        success: function (data) {
                            if (data == '1') {
                                $.messager.alert('', '申请解锁成功', 'info', function (r) {
                                    window.location.href = "sys_user";
                                });
                            } else {
                                $.messager.alert('操作提示', '申请解锁失败', 'error');
                            }
                        }
                    });
                });
            } else {
                $.messager.alert('操作提示', '请选择一条操作名为空的数据', 'info');
            }

            /* $.messager.alert('操作提示','是否要将此用户解锁,解锁后,用户可登录','question',function(r) {
                                $.ajax({
                                    url : 'editIsLockedSys_User',
                                    type : 'POST', //GET
                                    async : true, //或false,是否异步
                                    contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
                                    data : {"id" : id,"isLocked" : "N"},
                                    dataType : 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                                    success : function(data) {
                                        if (data.result == '1') { //如果返回1，解锁成功
                                            window.location.href = "sys_user";
                                        } else { //否则解锁失败
                                            $.messager.alert('操作提示','哎呦，此用户解锁失败','error');
                                        }
                                    }
                                });
            }); */
        } else if (isLocked == 'N') { //如果该用户未锁定，则加锁(即锁定用户)
            if (handlename == ' ') {
                $.messager.prompt('操作提示', '请填写锁定用户原因', function (r) {
                    if (r) {
                        $.ajax({
                            url: 'applyDoLock',
                            type: 'POST', //GET
                            async: true, //或false,是否异步
                            contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                            data: {"id": id, "reason": r, "randSession": "${authId}"},
                            dataType: 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                            success: function (data) {
                                if (data == '1') {
                                    $.messager.alert('', '申请锁定成功', 'info', function (r) {
                                        window.location.href = "sys_user";
                                    });
                                } else {
                                    $.messager.alert('操作提示', '申请锁定失败', 'error');
                                }
                            }
                        });
                    }
                });
            } else {
                $.messager.alert('操作提示', '请选择一条操作名为空的数据', 'info');
            }


            /* $.messager.prompt('操作提示', '请填写锁定用户原因', function(r){
                if(r){
                    $.ajax({
                        url : 'editIsLockedSys_User',
                        type : 'POST', //GET
                        async : true, //或false,是否异步
                        contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
                        data : {"id" : id,"isLocked" : "Y","reason":r},
                        dataType : 'json', //返回的数据格式：json/xml/html/script/jsonp/text
                        success : function(data) {
                            if (data.result == '1') { //如果返回1，解锁成功
                                window.location.href = "sys_user";
                            } else { //否则解锁失败
                                $.messager.alert('操作提示','哎呦，此用户解锁失败','error');
                            }
                        }
                    });
                }
            }); */
        }
    }
</script>
</body>
</html>
